/**
 * 
 * The timer class.
 * 
 * It starts when you create it.
 * You can then reset it to 0, or get the time past since
 * you created or reset it.
 * 
 * All times in milliseconds
 * 
 * @author Andrew
 * @creator Andrew
 * 
 * LAST UPDATED 2/4/12 Andrew
 */

public class Timer extends Time {
	
    private int timeAsInt;
    
    private int timeAtStart;
   
   public Timer() {
       super();
       // add all the times up from the mins, if a game actually lasts one hour ill eat my pants
       timeAsInt = (super.getMins() * 60 * 1000) + (super.getSecs() * 1000) + (super.getMili());
       timeAtStart = (super.getMins() * 60 * 1000) + (super.getSecs() * 1000) + (super.getMili());
   }
   
   // make sure the time is accurate
   public void Update() {
       super.update();
       timeAsInt = (super.getMins() * 60 * 1000) + (super.getSecs() * 1000) + (super.getMili());
   }
   // get the inital start time
   public int getStartTime() {
       return timeAtStart;
   }
   // get the time since it was last reset
   // but make sure to update it first! Or you will get bad results
   public double getDeltaTime() {
       Update();
       return (double) timeAsInt - timeAtStart;
   }
   // and reset it
   public void reset() {
       super.update();
       timeAsInt = (super.getMins() * 60 * 1000) + (super.getSecs() * 1000) + (super.getMili());
       timeAtStart = (super.getMins() * 60 * 1000) + (super.getSecs() * 1000) + (super.getMili());
       
   }
   // return the current time.
   public int getTime() {
       Update();
       return timeAsInt;
   }
   
}
